#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2022-1-8 23:03
from time import sleep

from appium.webdriver.common.mobileby import MobileBy
from selenium.common.exceptions import NoSuchElementException

from homework.task_app.base.base_page import BasePage


class MemberEditPage(BasePage):

    def delete_member(self, name):
        """删除成员"""
        # 点击删除成员按钮
        self.sroll_to_click('删除成员')
        self.find_and_click(MobileBy.XPATH, "//*[@text='确定']")
        sleep(1.5)

        # 获取删除后的查询结果
        try:
            ele_member_result_after = self.finds(MobileBy.XPATH,
                                                 f"//*[@class='android.widget.ListView']"
                                                 f"//*[@text='{name}']")
            after_result_num = len(ele_member_result_after)
        except NoSuchElementException:
            after_result_num = 0

        return after_result_num  # todo 删除前搜索结果数量、删除后搜索结果数量
